package 刷题10月.每日一题0930;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        //int arr[]=new int[]{3,2,8,1,1,10,9,-1};

        Scanner scan=new Scanner(System.in);
        String input=scan.nextLine();
        String arr[]=input.split(",");
        int arr1[]=new int[arr.length];
        for(int i=0;i<arr1.length;i++){
            arr1[i]=Integer.parseInt(arr[i]);
        }
        System.out.println(max(arr1));
    }
    public static int max(int arr[]){
        if(arr.length==0){
            return 0;
        }
        if(arr.length==1){
            return arr[0];
        }
        int temp=arr[0];
        int dp[]=new int[arr.length];
        dp[0]=arr[0];
        dp[1]=Math.max(dp[0],arr[1]);
        for (int i = 2; i <arr.length ; i++) {
            temp=Math.max(dp[i-2]+arr[i],arr[i]);
            dp[i]=Math.max(temp,dp[i-1]);
        }
        return dp[arr.length-1];
    }
}
